package cn.edu.scau.cmi.zengdefeng.Adapter;

import java.util.List;

public class SortUtil {
	public List<Integer> sortInt(List<Integer> intList){
	/*	Integer p=intList.get(0);快速排序
		Integer i=0;
		Integer j=intList.size()-1;
		while(i<j) {
			while((i<j)&&(intList.get(j)>p))
				j--;
			while((i<j)&&(intList.get(i)<p))
				i++;
			if(intList.get(i)==intList.get(i)&&(i<j))
					i++;
			else {
				int temp=intList.get(i);
				intList.set(i, intList.get(j));
				intList.set(j, temp);
			}
			
		}
		return intList;
	
		for(int i=0;i<intList.size()-1;i++) {冒泡排序
			for(int j=i+1;j<intList.size();j++) {
				Integer a = intList.get(i);
				Integer b = intList.get(j);
				if(a>b) {
					intList.set(i, b);
					intList.set(j, a);
				}
			}
		}
		return intList;	
		*/
		for (int i = 1; i < intList.size(); i++) {//插入排序
			if (intList.get(i) < intList.get(i - 1)) {
				int temp = intList.get(i);
				int j = i - 1;
				while (j >= 0 && temp < intList.get(j)) {
					intList.set(j + 1, intList.get(j));
					j--;
				}
				intList.set(j + 1, temp);
			}
		}
		return intList;
	}

}
